

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>流程表单数据字典</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../../static/lib/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../../static/lib/layuiadmin/style/admin.css" media="all">
    <style>
        html,body{height: 100%;}
        .layui-fluid{height: 96%;}
        .layui-row,.layui-card,.layui-col-xs12{height: 100%;}
    </style>

</head>
<body>


<div class="layui-fluid" id="LAY-component-grid-mobile">
    <div class="layui-row layui-col-space10">
        <div class="layui-col-xs12" style="height: 100%;">
            <div class="layui-card">
                <div class="layui-card-header">默认值权限配置</div>
                <div class="layui-card-body">
                    <div class="" style="border-bottom:0;padding:0;margin-bottom: 10px;">
                        <form class="layui-form" action="">
                            <table style="width:98%; table-layout:fixed;">
                                <tr>
                                    <td style='width:80px'>
                                        <a id="save" class="layui-btn layui-btn-sm st_back1"  onclick="save()" > 确  定</a>
                                    </td>
                                    <td style="text-align: right">
                                        <input type="checkbox" name="can-view" id="allView" lay-filter="allView" lay-skin="primary" title="是否显示（全选）" >
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>
                    <div id="wfActivityGrid" title="" showHeader="true"   url="/wf/activity/listAllByWfActivityNoStartEnd"
                         sizeList="[10,20,50,100]" pageSize="20" onrowdblclick="" page="true" style="margin-top: 20px;" >
                        <div property="columns" style="display: none;">
                            <div type="indexcolumn" width="40" headerAlign="center">序号</div>
                            <div field='activityName' width="48%"   headerAlign='center' allowSort='true'>活动名称</div>
                            <div field='view' width="48%"   headerAlign='center' allowSort='true' renderer="canView" >是否显示</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="../../../../static/lib/layuiadmin/layui/layui.js"></script>
<script src="../../../common/common.js"></script>
<script src="../../../common/jquery-3.3.1.min.js"></script>
<script src="../../../common/listTree.js"></script>
<script src="../../../common/dataGrid.js"></script>
<script>
    UserInfo.init();
    curpsnid = UserInfo.userId; //当前操人id
    cur_psn = UserInfo.userName; //当前操人
    cur_orgid= UserInfo.orgId;//当前人的机构iD
    cur_orgname= UserInfo.orgName;//当前人的机构名称
    var wfActivityList=new dataGrid("wfActivityGrid");
    var frameId = window.frameElement && window.frameElement.id || '';
    var formId = RequestURLParam.getParam("formId");
    var wfId = RequestURLParam.getParam("wfId");
    var viewId = RequestURLParam.getParam("viewId");
    var viewIds = viewId.split(",");
    var iframe = RequestURLParam.getParam("iframeId");
    node = $('#'+iframe,parent.document)[0].contentWindow.node;

    $(document).ready(function () {
        wfActivityList.load({"wfId" : wfId});

        layui.use(['form', 'layer', 'table', 'jquery'], function(){
            layer = layui.layer //弹层
            table = layui.table //表格
            form = layui.form //表单
            $ = layui.$ //JQuery

            //监听复选框
            form.on('checkbox(allView)', function(data){
                if(data.elem.checked){
                    $('input[name=can-view]').prop("checked",true);
                    $('input[name=can-view][id!=allView]').siblings('div').each(function (index) {
                        $(this).addClass("layui-form-checked");
                    })
                }else{
                    // $('input[name=can-view][id!=allView]').attr("checked");
                    $('input[name=can-view]').prop("checked",false);
                    $('input[name=can-view][id!=allView]').siblings('div').each(function (index) {
                        $(this).removeClass("layui-form-checked");
                    })
                }
            });
        });

    });

    function reloadGrid() {
        wfActivityList.reload({"wfWorkflow.formEditId" : formId});
    }

    function canView(e) {
        var row = e.record;
        var checked = '';
        try {
            viewIds.forEach(function(item,index){
                if (item == row.wfaId) {
                    checked = "checked";
                    throw new Error("EndIterative");
                }
            });
        } catch(e) {
            if(e.message!="EndIterative") throw e;
        };

        return '<input type="checkbox" mid="'+ row.wfaId +'" '+ checked+' name="can-view" lay-skin="primary">';
        // return '<input type="checkbox" mid="'+ row.id +'" '+ checked +' name="can-view" lay-skin="switch"  lay-text="是|否"/>';
    }

    //确定
    function save() {
        var v1 = "";
        var v2 = "";

        $('input[name=can-view][id!=allView]:checked').each(function () {
            v1 += ($(this).attr('mid').trim()+",");
        });
        var index = parent.layer.getFrameIndex(window.name);

        node.attr('default-show', v1);
        parent.layer.close(index);
    }

</script>
</body>
</html>